home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 293 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. Path: ausnews.austin.ibm.com!hook
  2. From: hook@austin.ibm.com (Gary R. Hook)
  3. Newsgroups: comp.lang.c,comp.os.ms-windows.nt.misc,comp.programming,comp.std.c,comp.unix.aix
  4. Subject: Re: function pointers
  5. Date: 3 Feb 1996 18:20:08 GMT
  6. Organization: AIX Development, IBM Austin
  7. Sender: hook@shocker.austin.ibm.com (Gary R. Hook)
  8. Message-ID: <4f090o$2hn4@ausnews.austin.ibm.com>
  9. References: <4eogio$gt0@giga.bga.com> <4eohgr$gt0@giga.bga.com> <sXEExQ9ytBGL084yn@csn.net> <4es7vo$bih@usenet.pa.dec.com>
  10. NNTP-Posting-Host: shocker.austin.ibm.com
  11. X-newsreader: xrn 8.01
  12.  
  13. In article <4es7vo$bih@usenet.pa.dec.com>, diamond@tko.dec.com (Norman Diamond) writes:
  14. > After seeing several followups which were either wrong or else technically
  15. > correct but non-responsive to the original poster's problem, and seeing
  16. > which newsgroups they were posted to, I wish to point out that only one
  17. > followup correctly answered the original poster's problem.
  18. > Thad Smith's posting with message-id <sXEExQ9ytBGL084yn@csn.net>
  19. > had the correct answer (and another partial answer with correct warning).
  20. > If you try relying on any of the others, you will get bitten someday, or
  21. > if not you then innocent bystanders will get bitten by your work.
  22.  
  23. Begging your pardon, but pretty much every one who responded to the post
  24. had a "correct" answer; the original question was how to get the code
  25. to compile on AIX.  The original code was incorrect, in that the casting
  26. that was being done did not really address the complaint from the
  27. compiler.  The "solution" is to properly perform the casts to the
  28. associated types, i.e. function pointers taking and returning the
  29. required data types, as opposed to casting to struct pointers, which
  30. doesn't affect the function pointer in the least.
  31.  
  32. The fact that what the original coder was trying to accomplish is
  33. quite non-portable, and can wreak havoc for others, was an appropriate
  34. comment by Thad, but the addition of his warning didn't make his
  35. answer any more correct than any of the others, did it?  Or perhaps
  36. we saw different responses to the posed question...
  37.  
  38. Finally, it may be worth pointing out that the NT MSVC++ and SVR4 C
  39. compiler are incorrect with respect to the ANSI standard (if that's
  40. what you're trying to write to) in that it is illegal to allow
  41. a cast _from_ an arbitrary pointer type _to_ a void pointer without
  42. a cast.  It is perfectly permissible to allow the compiler to
  43. convert from void pointers to other pointer types on the fly.  In
  44. _any_ case, it's flat-out dangerous and non-portable.
  45.  
  46. Good for XL C for refusing to compile this sort of code without
  47. complaint.
  48.  
  49. -- 
  50. ________________________________________________________________________
  51. Gary R. Hook                         | If you have any trouble sounding
  52. AIX Development, RS6000 Division     | condescending, find a Unix user
  53. IBM Corporation, Austin, Texas       | to show you how it's done.
  54. The above opinions are all mine.     | -Scott Adams, author of "Dilbert"
  55.